<!DOCTYPE html>

<html>
<head>
  <title>Record</title>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
  <link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
  <div id="container">
    <div id="background"></div>
    
      <ul id="jump_to">
        <li>
          <a class="large" href="javascript:void(0);">Jump To &hellip;</a>
          <a class="small" href="javascript:void(0);">+</a>
          <div id="jump_wrapper">
          <div id="jump_page">
            
              
              <a class="source" href="List.coffee.html">
                List.coffee.md
              </a>
            
              
              <a class="source" href="Map.coffee.html">
                Map.coffee.md
              </a>
            
              
              <a class="source" href="Record.coffee.html">
                Record.coffee.md
              </a>
            
              
              <a class="source" href="Set.coffee.html">
                Set.coffee.md
              </a>
            
              
              <a class="source" href="Stream.coffee.html">
                Stream.coffee.md
              </a>
            
              
              <a class="source" href="Tuple.coffee.html">
                Tuple.coffee.md
              </a>
            
              
              <a class="source" href="header.coffee.html">
                header.coffee.md
              </a>
            
          </div>
        </li>
      </ul>
    
    <ul class="sections">
        
        
        
        <li id="section-1">
            <div class="annotation">
              
              <div class="pilwrap ">
                <a class="pilcrow" href="#section-1">&#182;</a>
              </div>
              <h1 id="record">Record</h1>

            </div>
            
            <div class="content"><div class='highlight'><pre>	
	<span class="hljs-built_in">window</span>.Record = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Record</span></span>
	
		<span class="hljs-property">@Of</span>: Function.Cache.From<span class="hljs-function"><span class="hljs-params">(Object)</span>.<span class="hljs-title">To</span><span class="hljs-params">(Function)</span> <span class="hljs-params">(constructors)</span> -&gt;</span> 
		
			record = <span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">this</span></span>
			
				<span class="hljs-attribute">constructor</span>: <span class="hljs-function"><span class="hljs-params">(data={})</span> -&gt;</span>
					<span class="hljs-property">@_</span> = {}
					@[field] data[field] <span class="hljs-keyword">for</span> field <span class="hljs-keyword">in</span> <span class="hljs-property">@fields</span>
					
				<span class="hljs-attribute">fields</span>: ( field <span class="hljs-keyword">for</span> own field <span class="hljs-keyword">of</span> constructors )
			
			<span class="hljs-keyword">for</span> own field, constructor <span class="hljs-keyword">of</span> constructors
				<span class="hljs-keyword">do</span> <span class="hljs-function"><span class="hljs-params">(field,constructor)</span> -&gt;</span>
					record.prototype[field] = Function.overload [
						Function.From(Not Function) \
							Function.Of<span class="hljs-function"><span class="hljs-params">(constructor)</span>.<span class="hljs-title">Chaining</span> <span class="hljs-params">(value)</span> -&gt;</span>
								<span class="hljs-property">@_</span>[field] = value
						Function.From(Function) \
							Function.Chaining <span class="hljs-function"><span class="hljs-params">(fn)</span> -&gt;</span>
								@[field] fn.call <span class="hljs-keyword">this</span>, <span class="hljs-property">@_</span>[field]
						Function.From() \<span class="hljs-function">
							-&gt;</span> <span class="hljs-property">@_</span>[field]
					]
			
			<span class="hljs-keyword">return</span> record</pre></div></div>
            
        </li>
        
    </ul>
  </div>
</body>
</html>
